package map的使用;

import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class 出现次数最多的整数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        if (n<=0){
            return;
        }
        int[] a = new int[n];
        TreeMap<String, Integer> map = new TreeMap<>();
        for (int i = 0; i < a.length; i++) {
            a[i] = scanner.nextInt();
            map.put(String.valueOf(a[i]),0);
        }
        for (int i = 0; i < a.length; i++) {
            map.put(a[i]+"",map.get(a[i]+"")+1);
        }
        // 定义键的集合
        Set<String> strings = map.keySet();
        // 遍历键
        StringBuilder str = new StringBuilder();
        for (String key :
                strings) {
            str.append(key+" ");
        }
        String[] split = String.valueOf(str).split("\\s");
        // 定义最大值
        int max = map.get(split[0]);
        for (int i = 0; i < split.length; i++) {
            max = Math.max(max,map.get(split[i]));
        }
        // 遍历键，根据值找键
        for (String key : strings) {
            if (map.get(key)==max){
                System.out.println(key);
                return;
            }
        }
    }
}
